package android.slc.appbase.ui.vd

import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher

/**
 *
 * @Description:
 * @Author: sunlunchang
 * @CreateDate: 26/8/2021 下午 3:58
 *
 */
open class BaseCommonPageShelfVd<VB : BaseCommonPageShelfVmBox> : BaseAppVd<VB>() {
    private lateinit var addUiLauncher: ActivityResultLauncher<Bundle>

    override fun initView() {
        super.initView()
        if (this.vmBox.addRegisterActivityFunc != null) {
            addUiLauncher = activityResultCaller.registerForActivityResult(
                this.vmBox.addRegisterActivityFunc.targetActivityResultContract,
                this.vmBox.addRegisterActivityFunc.onTargetActivityResultCallback
            )
        }
    }

    override fun initMustCondition() {
        super.initMustCondition()
        vmBox.showAddUiOf.observe(lifecycleOwner) { itBundle ->
            addUiLauncher.launch(itBundle)
        }
    }
}